"""Module for several configuration options, contains all configurable things
in the program.

    TODO:
        Make it load a configuration file that overwrites defaults
        
        """

import os.path
import sys

CONFIG = {
          'server.socket_host': "192.168.2.4",
          'server.socket_port': 8050,
          'server.thread_pool': 5
}
# The outside directory, current working path if not frozen, else path
# where the frozen binary is located
OUTSIDE_DIR = os.path.realpath(os.path.dirname(sys.argv[0]))

# The directory for serving static files for cherrypy (the webui)
STATIC_DIR = os.path.join(os.path.realpath(os.path.dirname(sys.argv[0])),
                          "webui")

def data_dir(directory):
    """Returns a joined path between directory and
    the outside directory, creates the path if not available"""
    path = os.path.join(OUTSIDE_DIR, directory)
    try:
        os.makedirs(path)
    except (os.error):
        pass
    return path
    
def data_file(filename):
    """Returns a joined path between filename and the outside directory"""
    return os.path.join(OUTSIDE_DIR, filename)
